package server

import (
	. "com.mgface.disobj/apinode/api"
	. "com.mgface.disobj/apinode/handler"
	. "com.mgface.disobj/common"
	"fmt"
	log "github.com/sirupsen/logrus"
	"net/http"
)

func StartServer(na, mna string) {
	log.Debug("启动API节点...")
	log.Debug(fmt.Sprintf("节点地址:%s", na))
	log.Debug(fmt.Sprintf("元数据服务节点地址:%s", mna))
	//更新心跳
	go StartApiHeartbeat(mna,na)
	//刷新数据节点数据
	go RefreshDNData(mna)
	http.HandleFunc("/objects/", ApiHandler)
	http.HandleFunc("/locate/", LocateHandler)

	SupportServeAndGracefulExit(na)
}
